//
//  LBViewController.m
//  LBButtonImageTitlePosition
//
//  Created by liuboliu on 09/08/2021.
//  Copyright (c) 2021 liuboliu. All rights reserved.
//

#import "LBViewController.h"
#import <LBButtonImageTitlePosition/UIButton+ImageTitleLocationSpace.h>
#import <Masonry/Masonry.h>

@interface LBViewController ()

@property (nonatomic, strong) UIButton *firstButton;

@property (nonatomic, strong) UIButton *secondButton;

@property (nonatomic, strong) NSArray *array;

@end

@implementation LBViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.array = @[@"KK", @"n你好你好", @"啦啦啦啦啦啦啦", @"UUAJSDFK;JASDF",@"KKKKKKKKKKKKKKKKK"];
    self.view.backgroundColor = [UIColor whiteColor];
    self.firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.firstButton.backgroundColor = [UIColor lightGrayColor];
    [self.firstButton setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    self.firstButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.firstButton addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.firstButton];
    self.firstButton.contentEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 40);
    [self.firstButton setTitle:@"你好你哈" forState:UIControlStateNormal];
    [self.firstButton setImage:[UIImage imageNamed:@"account_verify_info"] forState:UIControlStateNormal];
    [self.firstButton rightImgWithIntervalSpace:40];
    
    [self.firstButton mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(10);
         make.top.mas_equalTo(100);
         make.height.mas_equalTo(50);
     }];
        
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)click
{
    NSLog(@"打印打印打印");
    NSInteger i = arc4random() % 5;
    NSString *title = self.array[i];
    self.firstButton.hasSetPositionAndSpace = NO;
    [self.firstButton setTitle:title forState:UIControlStateNormal];
    [self.firstButton rightImgWithIntervalSpace:40];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
